package com.yanxp.mybatis.mapper;

import com.yanxp.mybatis.entity.Order;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OrderMapper {

    @Results(id = "orderResults", value = {
            @Result(property = "id", column = "id"),
            @Result(property = "ordername", column = "ordername"),
            @Result(property = "detail", column = "detail_id", javaType = Order.class,
                    one = @One(select = "com.yanxp.mybatis.mapper.OrderDetailMapper.selectOne"))
    })
    @Select("select * from `order`")
    List<Order> selectAll();

    @Select("select * from `order` where user_id = #{uid}")
    List<Order> selectOne(Integer uid);
}
